﻿#region Copyright

// All Material Copyright © 2010 Dynamic Concepts Development Corp., All Rights Reserved.
//      Portions Copyright © 1984-2009 Dynamic Concepts Development Corp., All Rights Reserved.
// For further information please contact: SoftwareSupport@dynconcepts.com
// Dynamic Concepts Development Corp.  311 W 57th St. Suite #422, New York, NY 10019

#endregion

#region Using References

using System;
using Microsoft.Win32;

#endregion

namespace DynConDevCorp.OpenArch.DynAppFramework.Tiers.UserInterface.WPF.UIElements
{
    public class FileOpenDialog
    {
        #region Public Properies and Indexers

        public string DefaultExt { get; set; }
        public string DefaultFileName { get; set; }
        public string Filter { get; set; }
        public string SelectedFileName { get; private set; }

        #endregion

        #region Public Methods

        public bool? ShowDialog()
        {
            OpenFileDialog dlg = new OpenFileDialog
                                     {
                                         FileName = DefaultFileName,
                                         DefaultExt = DefaultExt,
                                         Filter = Filter
                                     };

            // Show open file dialog box
            bool? result = dlg.ShowDialog();

            // Process open file dialog box results
            SelectedFileName = result == true ? dlg.FileName : String.Empty;

            return result;
        }

        #endregion
    }
}